package com.wangyadong.hobby.schedule.jobtask.thread.thread1;

import java.util.concurrent.atomic.AtomicInteger;

public class TicketThread extends Thread {

    private String name;

    AtomicInteger value = new AtomicInteger();

    public TicketThread(String name) {
        this.name = name;
    }

    public TicketThread() {
    }


    private int index = 1;


    @Override
    public synchronized void run() {
        while (index < 50) {
            System.out.println(Thread.currentThread().getName() + " has " + (++index));
        }
    }

    public static void main(String[] args) {
        TicketThread ticket1 = new TicketThread("wyd1");
        ticket1.start();

        TicketThread ticket2 = new TicketThread("wyd1");
        ticket2.start();

        TicketThread ticket3 = new TicketThread("wyd1");
        ticket3.start();
        TicketThread ticket4 = new TicketThread("wyd1");
        ticket4.start();

//        int i = 0;
//        int j = 0;
//
//        System.out.println(i++);
//        System.out.println(++j);
//
//        System.out.println("i" + i);
//        System.out.println("j" + j);

    }
}
